package netective.engine;

import netective.api.gatherer.Captor;
import netective.gui.MainWindow;

/**
 * Broker between GUI and Captor.
 * @author Bartek
 *
 */
public class Engine {
	Captor manager;
	MainWindow window;
	
    public Captor getManager() {
		return manager;
	}

	public void setManager(Captor manager) {
		this.manager = manager;
	}

	public Engine() {
    	manager = new Captor();
    	window = new MainWindow();
    	window.createInstanceSettingsDevicesWindow(this);
    	window.startChartRefreshing();
    }
    
    public void printDeviceDetails() {
    	manager.printDevicesDetails();
    }
    
    public boolean openDevice(int index) {
    	return manager.openDevice(index, 65535, true, 20);
    	//window.setDevices(manager.getDevices());
    }
    
    public boolean openDevice(int index, int snaplen, boolean promics, int to_ms) {
    	return manager.openDevice(index, snaplen, promics, to_ms);
    }
    
    public void handlePackets() {
    	manager.handlePackets();
    }
    
    /*
     * Only one captor can be open in this moment!
     */
    public void closeCaptor() {
    	manager.closeCaptor();
    }
}
